import { GameCtrl } from "./GameCtrl";
import GameView from "./GameView/GameView";

const {ccclass, property} = cc._decorator;

@ccclass
export default class GameScene extends cc.Component {
    @property(cc.Prefab) gameViewPrefab:cc.Prefab = null;

    private gameCtrl:GameCtrl = null;
    private gameView:GameView = null;

    onLoad(){}

    start () {
        let gameViewNode = cc.instantiate(this.gameViewPrefab);
        this.gameView = gameViewNode.getComponent('GameView');
        this.node.addChild(this.gameView.node);
        this.gameCtrl = new GameCtrl();
        this.gameCtrl.init(this.gameView);
        this.gameCtrl.play();
    }

    onDestroy(){
        this.gameCtrl.exit(); 
    }
}
